﻿using DataModel.PublicModel.Typedef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataModel.Send.DataDef
{
    /// <summary>
    /// 发送报文请求历史数据DATA部分定义
    /// </summary>
    public class DataHis : DataBase
    {
        public DataHis()
        {
            SetRequest(Operator.hisdata);
        }
        DateTime fromtime;//起始时间（DATE TIME）
        DateTime totime;//截至时间（DATE TIME）
        List<string> meters;
        /// <summary>
        /// 请求起始时间
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "fromtime")]
        public string Fromtime
        {
            get
            {
                return fromtime.ToString("yyyy-MM-dd hh:mm:ss");
            }

            set
            {
                if (!DateTime.TryParse(value, out fromtime))
                {
                    fromtime = DateTime.Now;
                }
            }
        }
        /// <summary>
        /// 请求截止时间
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "totime")]
        public string Totime
        {
            get
            {
                return totime.ToString("yyyy-MM-dd hh:mm:ss");
            }

            set
            {
                if (!DateTime.TryParse(value, out totime))
                {
                    totime = DateTime.Now;
                }
            }
        }
        /// <summary>
        /// 待请求的仪表
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "meters")]
        public List<string> Meters
        {
            get
            {
                if (meters == null)
                    meters = new List<string>();
                return meters;
            }

            set
            {
                meters = value;
            }
        }
    }
}
